package com.soup.lab.spring.retry.service.usecase;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.retry.RetryCallback;
import org.springframework.retry.RetryContext;
import org.springframework.retry.listener.RetryListenerSupport;
import org.springframework.stereotype.Component;

@Component
public class InvokeRetryListener extends RetryListenerSupport {

    private static final Logger logger = LoggerFactory.getLogger(InvokeRetryListener.class);

    @Override
    public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
        logger.error("重试次数：{}", context.getRetryCount(), throwable);
    }

}
